package com.interview.juc;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Copyright (C), 2018-2020
 * FileName: ReenterLockDemo
 * Author:   kongfanyu
 * Date:     2020/11/25 14:20
 */
public class ReenterLockDemo {
    static Lock lock = new ReentrantLock();
    public static void main(String[] args) {
       new Thread( ()->{
           lock.lock();
           try {
               System.out.println("外层----");
               lock.lock();
               try
               {
                   System.out.println("内层======");
               } finally {
                   lock.unlock();
               }
           }finally {
               lock.unlock();
           }
       },"线程A" ).start();
    }
}
